<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
    <style>
        /* 设置星空背景 */
        body {
            background: url('https://source.unsplash.com/1600x900/?stars,night') no-repeat center center fixed;
            background-size: cover;
            color: white; /* 调整字体颜色以在深色背景上可见 */
        }
        table {
            background: rgba(0, 0, 0, 0.7); /* 半透明背景让表格更易读 */
            border-collapse: collapse;
            width: 100%;
            margin-bottom: 20px;
        }
        th, td {
            border: 1px solid white;
            text-align: left;
            padding: 8px;
        }
        th {
            background-color: rgba(255, 255, 255, 0.2);
        }
        tr:nth-child(even) {
            background-color: rgba(255, 255, 255, 0.1);
        }
        a {
            color: #FFD700; /* 金色链接颜色 */
            text-decoration: none;
        }
        a:hover {
            text-decoration: underline;
        }
        .btn-secondary {
            background-color: rgba(255, 255, 255, 0.2);
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            text-decoration: none;
            transition: background-color 0.3s;
        }
        .btn-secondary:hover {
            background-color: rgba(255, 255, 255, 0.4);
        }
    </style>
</head>
<body>
    {% if role == 'student' %}
        {% if assignments %}
            <table>
                <tr>
                    <th>作业序号</th>
                    <th>作业标题</th>
                    <th>作业内容</th>
                    <th>附件</th>
                    <th>作业状态</th>
                    <th>成绩</th>
                </tr>
                {% for assignment in assignments %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td>{{ assignment.title }}</td>
                    <td>{{ assignment.content }}</td>
                    <td>
                        {% if assignment.file_path %}
                            <a href="{{ url_for('assignments.download_file', filepath=assignment.file_path) }}" download>下载文件</a>
                        {% else %}
                            无附件
                        {% endif %}
                    </td>
                    <td>
                        {% if assignment.isSubmit is none %}
                            <a href="{{ url_for('assignments.submit', id=assignment.assignmentId, class_id=class_id) }} ">提交作业</a>
                        {% else %}
                            作业已提交
                        {% endif %}
                    </td>
                    <td>
                        {% if assignment.isCorrect is none %}
                            未批改
                        {% else %}
                            {{ assignment.isCorrect }}
                        {% endif %}
                    </td>
                </tr>
                {% endfor %}
            </table>
        {% else %}
            <p>暂无作业</p>
        {% endif %}

        已批改作业的加权平均成绩：{{ total_score }}

    {% elif role == 'teacher' %}
        <li><a href="{{ url_for('assignments.new_assignment', id=class_id) }}">布置作业</a></li>
        {% if assignments %}
            <table>
                <tr>
                    <th>作业序号</th>
                    <th>作业标题</th>
                    <th>作业内容</th>
                    <th>附件</th>
                    <th>作业完成情况</th>
                    <th>作业权重(1~10)</th>
                </tr>
                {% for assignment in assignments %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td>{{ assignment.title }}</td>
                    <td>{{ assignment.content }}</td>
                    <td>
                        {% if assignment.file_path %}
                            <a href="{{ url_for('assignments.download_file', filepath=assignment.file_path) }}" download>下载文件</a>
                        {% else %}
                            无附件
                        {% endif %}
                    </td>
                    <td>
                        <a href="{{ url_for('assignments.assignment_status', id=assignment.assignmentId, class_id=class_id) }}" >查看详情</a>
                    </td>
                    <td>{{ assignment.weight }}</td>
                </tr>
                {% endfor %}
            </table>
        {% else %}
            <p>暂无作业</p>
        {% endif %}
    {% endif %}
    <a href="/classes/classes" class="btn btn-secondary">返回</a>
</body>
</html>
